package gson;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import bean.DaShuai;
import bean.DaShuaiWithBirthday;
import json.ReadJSONSample;

public class ReadGsonSample {

	public static void main(String[] args) throws IOException {
		File file = new File(
				ReadJSONSample.class.getResource("/lidashuai.json")
				.getFile());
		String content = FileUtils.readFileToString(file);
		System.out.println(content);
		Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
		DaShuaiWithBirthday daShuai = gson.fromJson(content, DaShuaiWithBirthday.class);
		System.out.println(daShuai.getBirthday().toLocaleString());
		//
		System.out.println(daShuai.getMajor());
		System.out.println(daShuai.getMajor().getClass());
		
	}
}
